package com.blog.admin.controller;

import com.blog.admin.service.BlogLinkService;
import com.blog.admin.vo.BlogLinkVO;
import com.blog.vo.PageVO;
import com.blog.util.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 友情链接
 * @author tangqj
 * @Description
 * @create 2020/2/18 15:14
 */
@RestController
@RequestMapping("blogLinkController")
public class BlogLinkController {
    @Autowired
    BlogLinkService blogLinkService;


    @RequestMapping("getBlogLink")
    public Map<String,Object> getBlogLink(PageVO page,BlogLinkVO blogLinkVO){
        PageInfo<BlogLinkVO> result = blogLinkService.getBlogLink(page,blogLinkVO);
        Map<String,Object> data = new HashMap<>();
        data.put("count", result.getTotal());
        return Result.responeAjaxMap(true,"", result.getList(),data);
    }

    @RequestMapping("insertBlogLink")
    public Map<String,Object> insertBlogLink(BlogLinkVO blogLinkVO){
        boolean result = blogLinkService.insertBlogLink(blogLinkVO);
        return Result.responeAjaxMap(result,  result?"操作成功":"操作失败", "",null);
    }

    @RequestMapping("updateBlogLink")
    public Map<String,Object> updateBlogLink(BlogLinkVO blogLinkVO){
        boolean result = blogLinkService.updateBlogLink(blogLinkVO);
        return Result.responeAjaxMap(result,  result?"操作成功":"操作失败", "",null);
    }

    @RequestMapping("deleteBlogLinkById")
    public Map<String,Object> deleteBlogLinkById(String id){
        boolean result = blogLinkService.deleteBlogLinkById(id);
        return Result.responeAjaxMap(result,  result?"操作成功":"操作失败", "",null);
    }
}
